package main

import (
	"fmt"
	"sort"
)

func main()  {
	var arr = []int{1,-1,2,3,-3,-5,4,9,6,7,-2}
	fmt.Println(testsanshuzhihe(arr))
}

func testsanshuzhihe(arr []int) [][]int {
	sort.Ints(arr)
	fmt.Println(arr)

	var ret [][]int
	for i :=0;i <len(arr)-3;i++ {

		temp := 0-arr[i]
		j := i+1
		k := len(arr)-1
		for j < k {
			if arr[j] + arr[k] == temp {
				ret = append(ret,[]int{arr[i],arr[j],arr[k]})
				if j < k && arr[j] == arr[j+1] {
					j++
				}

				if j < k && arr[k] == arr[k-1] {
					k--
				}
				j++
				k--

			}else if arr[j] + arr[k] < temp {
				j++
			}else {
				k--
			}
		}

	}
	return ret
}